#pragma once

#include <AVUIFrameworkTemplate.h>

namespace AVUI {
class ContentPresenter;

class DataTemplate : public FrameworkTemplate
{
public:
    DECLARE_ELEMENT(DataTemplate, FrameworkTemplate);

#pragma region Public Methods

    /// <summary>Initializes a new instance of the <see cref="T:System.Windows.DataTemplate" /> class.</summary>
    DataTemplate() { };

    /// <summary>Initializes a new instance of the <see cref="T:System.Windows.DataTemplate" /> class with the specified <see cref="P:System.Windows.DataTemplate.DataType" /> property.</summary>
    /// <param name="dataType">If the template is intended for object data, this is the Type name of the data object. To refer to the Type name of the class, use the x:Type Markup Extension. If the template is intended for XML data, this is the string that represents the tag name of the data.</param>
    DataTemplate(Object* pDataType);

#pragma endregion Public Methods

#pragma region Public Properties

    TRefCountedPtr<Object> get_DataTemplateKey();
    IMPLEMENT_READONLY_REFERENCE_PROPERTY(DataTemplateKey, Object, false);

    /// <summary>Gets or sets the type for which this <see cref="T:System.Windows.DataTemplate" /> is intended. </summary>
    /// <returns>The default value is null.</returns>
    TRefCountedPtr<Object> get_DataType() { return m_pDataType; }
    void set_DataType(Object* pValue);
    IMPLEMENT_REFERENCE_PROPERTY(DataType, Object, false);

    /// <summary>Gets a collection of triggers that apply property values or perform actions based on one or more conditions.</summary>
    /// <returns>A collection of trigger objects. The default value is null.</returns>
    TriggerCollection* get_Triggers();
    IMPLEMENT_READONLY_REFERENCE_PROPERTY(Triggers, TriggerCollection, false);

#pragma endregion Public Properties

protected:

#pragma region Protected Methods

    /// <summary>Checks the templated parent against a set of rules.</summary>
    /// <returns />
    /// <param name="templatedParent">The element this template is applied to.</param>
    virtual void ValidateTemplatedParent(FrameworkElement* pTemplatedParent) AVUI_OVERRIDE;

#pragma endregion Protected Methods

public:

#pragma region Internal Methods

    virtual void SetTargetTypeInternal(const Type* pTargetType) AVUI_OVERRIDE;

#pragma endregion Internal Methods

#pragma region Internal Properties

    virtual TRefCountedPtr<Object> get_DataTypeInternal() { return get_DataType(); }
    static const Type* get_DefaultTargetType() { return &GET_TYPE(ContentPresenter); }
    virtual const Type* get_TargetTypeInternal() AVUI_OVERRIDE { return get_DefaultTargetType(); }
    virtual TriggerCollection* get_TriggersInternal() AVUI_OVERRIDE { return get_Triggers(); }

#pragma endregion Internal Properties

private:

#pragma region Private Fields

    TRefCountedPtr<Object> m_pDataType;
    TRefCountedPtr<TriggerCollection> m_pTriggers;

#pragma endregion Private Fields

};



}; // namespace AVUI
